package wyklad;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.File;
import java.net.URL;
import java.net.URISyntaxException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LicznikNaAtrybucie extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    int i = 0;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf8");
        PrintWriter pw = response.getWriter();

        pw.println("<html>");
        pw.println("<head>");
        pw.println("</head>");
        pw.println("<body>");
        pw.println("<h3>LicznikNaAtrybucie</h3>");

        // atrybut klasy
        synchronized (this) {
            pw.println("aktualna wartość: " + i++);
        }

        pw.println("</body>");
        pw.println("</html>");
        pw.close();
    }
}